package com.yyp.car.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.hdw.basic.dao.BaseDao;
import com.yyp.car.Idao.IStudentTTDao;
import com.yyp.car.model.StudentTT;
@Repository("studentTTDao")
public class StudentTTDao extends BaseDao<StudentTT> implements IStudentTTDao{

	@Override
	public Integer getMarks(int sid, int ttid) {
		String hql="select marks from StudentTT where sid='"+sid+"' and ttid='"+ttid+"'";
		return (Integer)this.queryObject(hql);
	}

	@Override
	public void updateMarks(int sid, int ttid, Integer marks) {
		String hql="update StudentTT s set s.marks='"+marks+"' where s.sid='"+sid+"' and s.ttid='"+ttid+"'";
		this.getSession().createQuery(hql).executeUpdate();
	}

	@Override
	public Integer findId(int sid, int ttid) {
		String hql="select s.id from StudentTT s where s.sid='"+sid+"' and s.ttid='"+ttid+"'";
		return (Integer)this.getSession().createQuery(hql).uniqueResult();
	}

	@Override
	public List<StudentTT> listMarksAndTtid(int sid) {
		String hql="select new StudentTT(s.marks,s.ttid) from StudentTT s where s.sid='"+sid+"' order by s.ttid asc";
		return this.list(hql);
	}


}
